﻿using BaseFramework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace LiteFramework.Model
{
    [Serializable]
    [ComVisible(true)]
    [Entity("SYS_Company")]
    public class Company : PersistentEntity<Company>
    {
        public Company() {
            this.Active = true;
            this.ClosingDate = new DateTime(2039, 12, 31, 23, 59, 59);
        }
        public Company(string code, string name)
            : this()
        {
            this.Code = code;
            this.Name = name;
        }

        /// <summary>
        /// 研发中心，允许查看所有公司的信息（本公司内部，按正常架构权限处理）
        /// </summary>
        public const string SysDevCode = "SYSDEV";
        /// <summary>
        /// 来宾机构代码。
        /// <para>　　所有注册用户，都归属于此机构，每个客户以一个机构代替</para>
        /// </summary>
        public const string CustomerCode = "CUSTOMER";

        #region Properties

        /// <summary>
        /// 主键
        /// </summary>
        [PrimaryKey(UnsavedValue = "-1")]
        public int Id { get; private set; }
        /// <summary>
        /// 启用
        /// </summary>
        [Property]
        [DisplayName("启用")]
        public bool Active { get; set; }
        /// <summary>
        /// 公司代号
        /// </summary>
        [Property]
        [DisplayName("公司代号")]
        public string Code { get; private set; }
        /// <summary>
        /// 公司名
        /// </summary>
        [Property]
        [DisplayName("公司名")]
        public string Name { get; set; }
        /// <summary>
        /// 有效期
        /// </summary>
        [Property]
        [DisplayName("有效期")]
        public DateTime ClosingDate { get; set; }
        /// <summary>
        /// 公司英文名
        /// </summary>
        [Property]
        [DisplayName("公司英文名")]
        public string NameEn { get; set; }
        /// <summary>
        /// 主页
        /// </summary>
        [Property]
        [DisplayName("主页")]
        public string HomePage { get; set; }
        /// <summary>
        /// 电话
        /// </summary>
        [Property]
        [DisplayName("电话")]
        public string Tel { get; set; }
        /// <summary>
        /// 电话2
        /// </summary>
        [Property]
        [DisplayName("电话2")]
        public string Tel2 { get; set; }
        /// <summary>
        /// 传真
        /// </summary>
        [Property]
        [DisplayName("传真")]
        public string Fax { get; set; }
        /// <summary>
        /// 传真2
        /// </summary>
        [Property]
        [DisplayName("传真2")]
        public string Fax2 { get; set; }
        /// <summary>
        /// 电子邮箱
        /// </summary>
        [Property]
        [DisplayName("电子邮箱")]
        public string Email { get; set; }
        /// <summary>
        /// 地址
        /// </summary>
        [Property]
        [DisplayName("地址")]
        public string Address { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        [Property]
        [DisplayName("备注")]
        public string Remark { get; set; }
        #endregion

        public override string ToString()
        {
            return this.Name;
        }
    }
}